import { LoginType } from '@/enums/request.enums';
import { NormalRequest } from './request.normal';
import { SilentRequest } from './request.silent';

/**
 * 普通请求
 */
export const normalRequest = new NormalRequest('default', '123456', LoginType.Normal);

/**
 * 静默请求
 */
export const silentRequest = new SilentRequest('client', '123456', LoginType.Silent);

/**
 * 全局请求方法
 * @param options 请求选项
 * @returns  Promise
 */
export function request<T = any>(options: RequestOptions) {
  if (options.silentLogin) {
    return silentRequest.request<T>(options);
  }
  return normalRequest.request<T>(options);
}
